package com.rownext.kernel.logging.impl 
{
	import flash.events.Event;
	
	import com.rownext.kernel.logging.ILogger;
	import com.rownext.kernel.logging.LogLevel;	

	/**
	 * 内部类，<code>ILogger</code>接口的代理实现类
	 * <code>LogContext.getLogger</code>函数返回此对象，
	 * 可以被其他的实现<code>ILogger</code>接口的实例动态替换
	 * TODO 事件需要在此类定义？
	 * 
	 * @author Wang Kang
	 */
	internal class LoggerProxy implements ILogger
	{
		public function LoggerProxy(logger:ILogger)
		{
			_proxy = logger;
		}

		public function trace(message:String):void
		{
			_proxy.trace(message);
		}

		public function debug(message:String):void
		{
			_proxy.debug(message);
		}

		public function info(message:String):void
		{
			_proxy.info(message);
		}

		public function warn(message:String, error:Error = null):void
		{
			_proxy.warn(message, error);
		}

		public function error(message:String, error:Error = null):void
		{
			_proxy.error(message, error);
		}

		public function fatal(message:String, error:Error = null):void
		{
			_proxy.fatal(message, error);
		}

		public function isTraceEnabled():Boolean
		{
			return _proxy.isTraceEnabled();
		}

		public function isDebugEnabled():Boolean
		{
			return _proxy.isDebugEnabled();
		}

		public function isInfoEnabled():Boolean
		{
			return _proxy.isInfoEnabled();
		}

		public function isWarnEnabled():Boolean
		{
			return _proxy.isWarnEnabled();
		}

		public function isErrorEnabled():Boolean
		{
			return _proxy.isErrorEnabled();
		}

		public function isFatalEnabled():Boolean
		{
			return _proxy.isFatalEnabled();
		}

		public function dispatchEvent(event:Event):Boolean
		{
			return _proxy.dispatchEvent(event);
		}

		public function hasEventListener(type:String):Boolean
		{
			return _proxy.hasEventListener(type);
		}

		public function willTrigger(type:String):Boolean
		{
			return _proxy.willTrigger(type);
		}

		public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
		{
			_proxy.removeEventListener(type, listener);
		}

		public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
		{
			_proxy.addEventListener(type, listener, useCapture, priority, useWeakReference);
		}

		public function get name():String
		{
			return _proxy.name;
		}

		public function get level():LogLevel
		{
			return _proxy.level;
		}

		public function set level(level:LogLevel):void
		{
			_proxy.level = level;
		}

		private var _proxy:ILogger;
	}
}
